/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nominalitzacions.persistance;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.text.Document;
import nominalitzacions.ui.PrincipalView;

/**
 *
 * @author genis
 */
public class TextDataManager {

    private File text;

    public TextDataManager(String path) {
        text = new File(path);

    }
    public String openText() {
        String linea ="";
        try {
            BufferedReader entrada = new BufferedReader(new FileReader(text));
            try {
                    while(entrada.ready()) {
                    linea += entrada.readLine() + System.getProperty("line.separator");
                }

            } catch (IOException ex) {
                Logger.getLogger(TextDataManager.class.getName()).log(Level.SEVERE, null, ex);
             }
        } catch (FileNotFoundException ex) {
            Logger.getLogger(TextDataManager.class.getName()).log(Level.SEVERE, null, ex);
        }
        return linea;
    }
    /*public void saveText(String text,String path) throws IOException {
        File save = new File(path);
        FileWriter dicoWriter = new FileWriter(save);
        BufferedWriter dicoBuffer = new BufferedWriter(dicoWriter);
        dicoBuffer.write(text);
        dicoBuffer.newLine();
        ArrayList<String> dico = d.getAllDiccionary();
        Iterator<String> iterator = dico.iterator();
        while (iterator.hasNext() ) {
            dicoBuffer.write(iterator.next() );
            dicoBuffer.newLine();
        }
        dicoBuffer.close();
    }*/
}